package com.xiaoxi.exam.service;

import com.xiaoxi.exam.dao.DiscountMapper;
import com.xiaoxi.exam.model.Discount;
import com.xiaoxi.exam.model.DiscountExample;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DiscountService {

  @Autowired
  private DiscountMapper discountMapper;

  public List<Discount> getByUserId(long userId) {
    DiscountExample example = new DiscountExample();
    example.or().andUserIdEqualTo(userId).andDeletedAtIsNull();
    return discountMapper.selectByExample(example);
  }

  public Discount getById(long id) {
    return discountMapper.selectByPrimaryKey(id);
  }

}
